<?php
namespace App\Http\Controllers\Open;
use App\Facades\Site;
use App\Http\Controllers\Common\CommonController;
use App\Models\Personal\Resume;
use App\Repositories\Eloquent\YiwangAccessToken;

class JobSearchController extends CommonController{

    public function index(){
        $user = auth()->guard('personal')->user();
        if(!empty($user->uid)){
            $resumeInfo = Resume::where('uid',$user->uid)->where('default','1')->first();
        }
        $yiwangAccessToken = new YiwangAccessToken();
        $accessToken=$yiwangAccessToken->getAccessToken();
        $data=array(
            'unionid'=>Site::get('yiwang_unionid'),
            'clientid'=>!empty($resumeInfo->id)?$resumeInfo->id:0,
            'access_token'=>$accessToken
        );
        $json=$yiwangAccessToken->curlPost("https://www.1wyun.com/get_job_url",$data);
        $json=json_decode($json);
        if(!empty($json->url)){
            return redirect($json->url);

        }else{
            echo "链接平台失败或错误的参数!";
        }
    }
}

